package logic

import (
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddressAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddressAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressAddLogic {
	return &AddressAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 地址添加
func (l *AddressAddLogic) AddressAdd(in *user.AddressAddRequest) (*user.AddressAddResponse, error) {
	err := dao.AddressAdd(int32(in.UserId), in.Address)
	if err != nil {
		pkg.Error("添加失败", zap.Error(err))
		return nil, err
	}

	return &user.AddressAddResponse{Msg: "地址添加成功"}, nil

}
